package cn.actoncode.boot.module.ai.service.chat;

import cn.actoncode.boot.module.ai.dal.dataobject.chat.ChatRecordDO;
import cn.actoncode.boot.module.ai.dal.mapper.chat.ChatRecordMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 聊天记录 Service 实现类
 *
 * @author bin
 */
@Service
@Valid
@Slf4j
public class ChatRecordServiceImpl implements ChatRecordService {

    @Resource
    private ChatRecordMapper chatRecordMapper;

    @Override
    public void insertChatRecord(Long userId, Long intelligentAgentId, String prompt, String text) {
        ChatRecordDO chatRecordDO = new ChatRecordDO();
        chatRecordDO.setUserId(userId);
        chatRecordDO.setIntelligentAgentId(intelligentAgentId);
        chatRecordDO.setPrompt(prompt);
        chatRecordDO.setText(text);
        chatRecordMapper.insert(chatRecordDO);
    }

    @Override
    public void clearChat(Long userId) {
        chatRecordMapper.clearChat(userId);
    }

    @Override
    public ChatRecordDO getChatRecord(Long id) {
        return chatRecordMapper.selectById(id);
    }

    @Override
    public List<ChatRecordDO> getChatRecordList(Long userId) {
        return chatRecordMapper.getChatRecordList(userId);
    }
}
